﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Model;
using System.Data;

namespace DAL
{
  public  class stutableDAL
    {
        public static stutable GetUser(string username, string pwd)
        {
            string sql = $"select * from stutable where sno=@username and password=@pwd";
            SqlParameter[] sqlParameter =
            {
                new SqlParameter("@username",username),
                new SqlParameter("@pwd",pwd)
            };
            DataTable dt = DBHelper.ExcuteTable(sql, sqlParameter);
            //判断数据是否为空
            if (dt.Rows.Count > 0)
            {
                //对用户名和密码，角色进行检查
                stutable model = new stutable();
                model.sno =Convert.ToInt32( dt.Rows[0]["sno"]);
                model.password = Convert.ToString(dt.Rows[0]["password"]);
                model.role = Convert.ToInt32(dt.Rows[0]["role"]);
                return model;
            }
            return null;
        }

    }
}
